<template>
	<view class="dsfdsBody">
		<view class="page-content header-clear-medium">
			<view class="content mt-3">
				<view class="tabs tabs-box" id="tab_group">
					<view class="tab-controls rounded-s border-highlight">
						<a class="font-13  color-highlight" @click="getSelType('1')"
							:class="{collapsed:isSelType==1}">合约</a>
						<a class="font-13 color-highlight " @click="getSelType('2')"
							:class="{collapsed:isSelType==2}">激活</a>
						<a class="font-13 color-highlight" @click="getSelType('3')"
							:class="{collapsed:isSelType==3}">记录</a>
					</view>
					<view class="mt-3"></view>
					<uni-collapse v-model="isSelType" accordion @change="change">
						<uni-collapse-item ref='one' name="1" :show-arrow="false" :show-animation="true">
							<view class="collapse">
								<view class="card card-style mlmr0">
									<view class="card-header">
										账户详情
									</view>
									<view class="card-body">
										<view class="Smain_borderBox  ">
											<view class="contract_profile ">
												<image src="../../static/img/package-02.png" width="45px" mode="">
												</image>
												<view v-if="userinfos.member">
													<span>等级: <span class="badge bg-secondary">&nbsp;{{userinfos.member.level_name}}</span></span>
													<view>注册日期: {{userinfos.member.created_at}}</view>
												</view>
											</view>
											<view class="contract_username" style="display: none;">ceshi66</view>
										</view>
									</view>
								</view>

								<view class="card card-style mlmr0">
									<view class="card-header">
										合约详情
									</view>
									<image v-if="!contractdetail.insured" class="nodata" src="../../static/timg/nodata.png" mode=""></image>
									<view v-else class="card-body">
										<view class="flex1">
											<image :src="'../../static/img/package-0'+ contractdetail.insured.shop_id +'.png'" mode=""></image>
											<view>{{contractdetail.insured.shop_title}}</view>
										</view>
										<view class="flex2">
											<view class="items">
												<view>受保金额</view>
												<view>{{contractdetail.insured.protect_fee}}</view>
											</view>
											<view class="items">
												<view>状态</view>
												<view v-if="contractdetail.insured.status == 0" class="green">受保中</view>
												<view v-if="contractdetail.insured.status == 1" class="green">已完成</view>
												<view v-if="contractdetail.insured.status == 2" class="green">已发放</view>
											</view>
										</view>
										<view class="flex2">
											<view class="items">
												<view>开始时间</view>
												<view>{{formatDate(contractdetail.insured.start_time)}}</view>
											</view>
											<view class="items">
												<view>结束时间</view>
												<view>{{formatDate(contractdetail.insured.end_time)}}</view>
											</view>
										</view>
										<view class="flex2">
											<view class="items">
												<view>退保金额</view>
												<view>{{contractdetail.insured.settle_fee}}</view>
											</view>
											<view class="items">
												<view>退保金额(实际)</view>
												<view>{{contractdetail.insured.settle_fee2}}</view>
											</view>
										</view>
										<view class="flex2">
											<view class="items">
												<view>游戏次数</view>
												<view>{{contractdetail.insured.total_count}}</view>
											</view>
											<view class="items">
												<view>一档保护</view>
												<view>{{contractdetail.insured.first_fee}}</view>
											</view>
										</view>
									</view>
								</view>

								<view class="card card-style mlmr0">
									<view class="card-header">
										索赔详情
									</view>
									<image v-if="!contractdetail.claimlog" class="nodata" src="../../static/timg/nodata.png" mode=""></image>
									<view v-else class="card-body">
										<view class="flex1">
											<image :src="'../../static/img/package-0'+ contractdetail.claimlog.shop_id +'.png'" mode=""></image>
											<view>{{contractdetail.claimlog.shop_title}}</view>
										</view>
										<view class="flex2">
											<view class="items">
												<view>索赔金额</view>
												<view>{{contractdetail.claimlog.shop_price}}</view>
											</view>
											<view class="items">
												<view>状态</view>
												<view v-if="contractdetail.claimlog.status == 0" class="green">受保中</view>
												<view v-if="contractdetail.claimlog.status == 1" class="green">已完成</view>
												<view v-if="contractdetail.claimlog.status == 2" class="green">已发放</view>
												<view v-if="contractdetail.claimlog.status == 4" class="red">已驳回</view>
											</view>
										</view>
										<view class="flex2">
											<view class="items">
												<view>材料</view>
												<view class="flex3" v-if="contractdetail.claimlog.images">
													<image v-for="(items,indexs) in contractdetail.claimlog.images" :key="indexs" @click="clickImg(contractdetail.claimlog.images,indexs)" :src="baseURLs + items" mode=""></image>
												</view>
												<view v-else>无</view>
											</view>
											<view class="items">
												<view>申请时间</view>
												<view>{{contractdetail.claimlog.protect_date}}</view>
											</view>
										</view>
									</view>
								</view>
							</view>
						</uni-collapse-item>
						<uni-collapse-item ref='two' name="2" :show-arrow="false" :show-animation="true">
							<view class="collapse">
								<view class="row">
									<view class="col-sm-1 col-md-2 col-lg-4" v-for="(item,index) in baoxianList" :key="index">
										<view class="card card-style mlmr0">
											<view class="ap_con main_borderBox pb-2 ">
												<view class="package_top">
													<view class="right_package">
														<image :src="'../../static/img/package-0'+(index+1)+'.png'" mode=""></image>
														<span class="ml-5 font-weight-bold">{{item.title}}</span>
														<view class="font-weight-normal">RMB {{item.suanli}}</view>
													</view>
													<view class="right_packageTow">
														<image src="../../static/img/youjiantou.png" mode=""></image>
													</view>
												</view>
												<view class="protect_fee">
													<span>套餐最高保费:&nbsp;<b>{{item.gas}}</b></span>
												</view>

												<view class="list_row">
													<view class="head-1 col_1">下单数量</view>
													<view class="head-1 col_2">单</view>
													<view class="head-1 col_2">赢</view>
													<view class="head-1 col_3">保费</view>
												</view>
												<view class="list_row inner_ap_list"  v-for="(it,ind) in item.guige" :key="ind">
													<view class="head-1 col_1">{{it.sort}}</view>
													<view class="head-2 col_2">{{it.dan_num}}</view>
													<view class="head-2 col_2">{{it.win}}</view>
													<view class="head-2 col_3">{{it.bao}}</view>
												</view>
											</view>
										</view>
									</view>
								</view>
							</view>
						</uni-collapse-item>
						<uni-collapse-item ref='three' name="3" :show-arrow="false" :show-animation="true">
							<view class="collapse" id="tab_History">
								<view>
									<view class="cards mlmr0" v-for="(item,index) in shoubaojilu" :key="index">
										<view class="flex1">
											<image :src="'../../static/img/package-0'+ item.shop_id +'.png'" mode=""></image>
											<view>{{item.shop_title}}</view>
										</view>
										<view class="flex2">
											<view class="items">
												<view>受保金额</view>
												<view>{{item.protect_fee}}</view>
											</view>
											<view class="items">
												<view>状态</view>
												<view v-if="item.status == 0" class="green">受保中</view>
												<view v-if="item.status == 1" class="green">已完成</view>
												<view v-if="item.status == 2" class="green">已发放</view>
											</view>
										</view>
										<view class="flex2">
											<view class="items">
												<view>开始时间</view>
												<view>{{formatDate(item.start_time)}}</view>
											</view>
											<view class="items">
												<view>结束时间</view>
												<view>{{formatDate(item.end_time)}}</view>
											</view>
										</view>
										<view class="flex2">
											<view class="items">
												<view>退保金额</view>
												<view>{{item.settle_fee}}</view>
											</view>
											<view class="items">
												<view>退保金额(实际)</view>
												<view>{{item.settle_fee2}}</view>
											</view>
										</view>
										<view class="flex2">
											<view class="items">
												<view>游戏次数</view>
												<view>{{item.total_count}}</view>
											</view>
											<view class="items">
												<view>一档保护</view>
												<view>{{item.first_fee}}</view>
											</view>
										</view>
									</view>
								</view>
							</view>
						</uni-collapse-item>
					</uni-collapse>
				</view>
			</view>
		</view>
		<view class="footer-bar" :class="cixi ? '':'footer-bar-detached'">
			<view class="fbitem" @click="goSwichPage('/pages/index/index')">
				<view class="image">
					<image src="../../static/timg/shouye.png" mode=""></image>
				</view>
				<view class="text">首页</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/contract/contract')">
				<view class="image">
					<image src="../../static/timg/heyue.png" mode=""></image>
				</view>
				<view class="text">合约</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/user/assets')">
				<view class="image">
					<image src="../../static/timg/zichan.png" mode=""></image>
				</view>
				<view class="text">资产</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/user/claim')">
				<view class="image">
					<image src="../../static/timg/suopei.png" mode=""></image>
				</view>
				<view class="text">索赔</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		baoxianList,
		getuserinfo,
		baoxian_my_order,
		contract_details
	} from '../../api/api.js'
	import { baseURL } from '@/api/http.js'
	export default {
		components: {},
		data() {
			return {
				isSelType: "1",
				cixi: false,
				baoxianList: [],
				userinfos:[],
				
				baseURLs: baseURL,
				shoubaojilu:[],
				page:1,
				contractdetail:[]
			};
		},
		created() {},
		onLoad() {
			this.getuserinfofc()
			this.getbaoxianList()
			this.getcontractdetail()
		},
		onPageScroll(e) {
			if (e.scrollTop > 0) {
				this.cixi = true
			} else {
				this.cixi = false
			}
		},
		methods: {
			getuserinfofc(){
				let datas = {
					type:1
				}
				getuserinfo(datas).then(res => {
					if(res.data.status.errorCode == 0){
						this.userinfos = res.data.data
					}
				}).catch(err => {
					console.log(err)
				})
			},
			getbaoxianList() {
				let datas = {}
				baoxianList(datas).then(res => {
					if (res.data.status.errorCode == 0) {
						console.log(res.data.data);
						this.baoxianList=res.data.data;
					}
				}).catch(err => {
					console.log(err)
				})
			},
			getcontractdetail(){
				contract_details().then(res => {
					if (res.data.status.errorCode == 0) {
						this.contractdetail = res.data.data
					}
				}).catch(err => {
					console.log(err)
				})
			},
			getshoubaoorder(){
				let datas = {
					page:this.page
				}
				baoxian_my_order(datas).then(res => {
					if(res.data.status.errorCode == 0){
						this.shoubaojilu = res.data.data.data
					}
				}).catch(err => {
					console.log(err)
				})
			},
			getSelType(num) {
				this.isSelType = num;
				if(num == 3){
					this.getshoubaoorder()
				}
				switch (this.isSelType) {
					case '1':
						this.$refs.one.isOpen = true;
						this.$refs.two.isOpen = false;
						this.$refs.three.isOpen = false;
						break;
					case '2':
						this.$refs.one.isOpen = false;
						this.$refs.two.isOpen = true;
						this.$refs.three.isOpen = false;
						break;
					case '3':
						this.$refs.one.isOpen = false;
						this.$refs.two.isOpen = false;
						this.$refs.three.isOpen = true;
						break;
				}
			},
			clickImg(list,e){
				let lists = []
				for(let i = 0;i < list.length;i++){
					lists.push(this.baseURLs + list[i])
				}
				uni.previewImage({
					urls: lists, //需要预览的图片http链接列表，多张的时候，url直接写在后面就行了
					current: e, // 当前显示图片的http链接，默认是第一个
					success: function(res) {},
					fail: function(res) {},
					complete: function(res) {},
				})
			},
			formatDate(value) {
				const data = new Date(value * 1000);
				const month = data.getMonth() + 1;
				const day = data.getDate();
				const year = data.getFullYear();
				const hours = data.getHours();
				const minutes = data.getMinutes();
				const seconds = data.getSeconds();
				const formattedTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
				return formattedTime;
			},
			goSwichPage(page) {
				uni.navigateTo({
					url: page
				})
			},
			change(e) {
				console.log(e);
			},
		},
	};
</script>


<style scoped lang="scss">
	.fbitem {
		color: #818181;
		position: relative;
		flex: 1 1 auto;
		padding-top: 24rpx;

		.image {
			height: 48rpx;
			margin-top: -4rpx;

			image {
				width: 36rpx;
				height: 36rpx;
			}
		}

		.text {
			height: 48rpx;
			margin-top: -6rpx;
			font-size: 24rpx;
			opacity: 0.7;
			color: #818181;
		}
	}
</style>
<style scoped>
	* {
		box-sizing: border-box;
	}

	/deep/.uni-collapse {
		border-top: 0;
		border-bottom: 0;
		background-color: transparent;
	}

	/deep/.uni-collapse-item__title-box {
		display: flex;
		align-items: center;
		height: 0px;
		line-height: 0px;
		background-color: transparent;
		cursor: pointer;
		border-bottom: 0;
		font-size: 13px;
		font-weight: 500;
		transition: border-bottom-color .3s;
		outline: 0;
	}

	/deep/.uni-collapse-item__wrap {
		will-change: height;
		background-color: transparent;
		overflow: hidden;
		box-sizing: border-box;
		border-bottom: 0;
	}

	/deep/.uni-icons {
		display: none;
	}

	.dsfdsBody {
		width: 100%;
		min-height: 100vh;
		background-color: #f1f1f7;
		font-size: 14px;
		font-family: "Nunito", sans-serif !important;
		line-height: 24px !important;
		color: #747474 !important;
	}

	.header-clear-medium {
		padding-top: calc(calc(55px + 30px) +(env(safe-area-inset-top))* 0.8) !important;
	}

	.page-content {
		position: relative;
		overflow-x: hidden;
		transition: all 250ms ease;
		z-index: 2;
		padding-bottom: calc(60px +(env(safe-area-inset-bottom))* 1.1);
	}

	.content {
		position: relative;
		margin: 20px 20px 20px 20px;
	}

	.mt-3 {
		margin-top: 1rem !important;
	}

	.tabs-box .tab-controls {
		overflow: hidden;
		display: flex;
		border: solid 1px rgba(0, 0, 0, 0.07);
	}

	.tabs .tab-controls {
		font-weight: 600;
		font-family: "Nunito", sans-serif;
	}

	.rounded-s {
		border-radius: 15px !important;
	}

	.border-highlight {
		border-color: #4A89DC !important;
	}



	.tabs-box .tab-controls a {
		transition: all 200ms ease;
		overflow: hidden;
		text-align: center;
		border-right: solid 1px rgba(0, 0, 0, 0.07);
		width: 100%;
		margin: auto;
		color: #000;
		line-height: 38px;
	}

	.color-highlight {
		font-size: 13px !important;
		color: #4A89DC !important;
	}

	.collapse {
		min-height: 100vh;
		padding-bottom: 50px;
	}

	.collapsed {
		background-color: #4A89DC;
		border-color: #4A89DC;
		color: #FFF !important;
		pointer-events: none;
	}

	.collapsimg {
		height: 0;
		overflow: hidden;
		transform: height 0.35s ease;
	}

	.mt-3 {
		margin-top: 1rem !important;
	}

	.mlmr0 {
		margin-left: 0;
		margin-right: 0;
	}

	.card-style {
		margin: 0px 0px 15px 0px;
		border-radius: 10px;
		box-shadow: rgb(0 0 0 / 30%) 0px 30px 60px -30px, rgb(10 37 64 / 35%) 0px -2px 6px 0px inset;
	}

	.card-style {
		overflow: hidden;
		border: none;
		background-size: cover;
		background-repeat: no-repeat;
		background-position: center center;
	}

	.card {
		position: relative;
		display: flex;
		flex-direction: column;
		min-width: 0;
		word-wrap: break-word;
		background-color: #fff;
		background-clip: border-box;
	}

	.card-header:first-child {
		border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0;
	}

	.card-header {
		padding: 0.5rem 1rem;
		margin-bottom: 0;
		background-color: rgba(0, 0, 0, 0.03);
		border-bottom: 1px solid rgba(0, 0, 0, 0.125);
	}

	.card-body,
	.card-top,
	.card-center,
	.card-bottom {
		z-index: 3;
	}

	.card-body {
		flex: 1 1 auto;
		padding: 1rem 1rem;
	}

	.contract_profile {
		display: flex;
		align-items: center;
	}

	.contract_profile image {
		width: 45px;
		height: 45px;
		object-fit: cover;
		object-position: center;
		margin-right: 16px;
	}

	.contract_profile view {
		font-size: 11px;
		font-weight: normal;
		color: #797979;
	}

	.badge {
		display: inline-block;
		padding: 0.35em 0.65em;
		font-size: 0.75em;
		font-weight: 700;
		line-height: 1;
		color: #fff;
		text-align: center;
		white-space: nowrap;
		vertical-align: baseline;
		border-radius: 0.25rem;
	}

	.bg-secondary {
		background-color: rgba(108, 117, 125, 1) !important;
	}

	.contract_username {
		font-size: 15px;
		font-weight: bold;
		color: #2a2a2a;
		padding-top: 12px;
	}

	.new_package_box .top_package {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.top_package .left_package {
		width: auto;
		display: flex;
		align-items: center;
	}

	.top_package .left_package image {
		width: 60px;
		height: 60px;
		margin: 0 10px 0 0;
	}

	.left_package .inner_left view {
		font-size: 16px;
		color: #2a2a2a;
	}

	.top_package .right_package {
		width: 45%;
		text-align: right;
	}

	.right_package .inner_right_top {
		display: flex;
		align-items: center;
		padding-bottom: 16px;
		justify-content: flex-end;
	}

	.right_package .inner_right_top span {
		font-size: 10px;
		line-height: 1.2;
		padding-right: 6px;
		padding-left: 10px;
	}

	.right_package .inner_right_top image {
		width: 250px;
		height: 65px;
	}

	image,
	svg {
		vertical-align: middle;
	}

	.package_status image {
		width: 12px;
		height: 12px;
		margin-right: 2px;
	}

	.package_status span {
		font-size: 12px;
		color: #f00;
		font-weight: normal;
	}

	.bottom_profile_package {
		text-align: left;
	}

	.contract_details_dates {
		font-size: 12px;
		font-weight: normal;
		color: #797979;
		/* line-height: 1.75; */
		padding-top: 18px;
	}

	.date_wrap {
		display: flex;
		align-items: center;
		padding-bottom: 3px;
	}

	.main_borderBox {
		padding: 15px 16px;
	}

	.date_wrap view {
		width: 110px;
	}

	.contract_details_dates span {
		font-size: 12px;
		font-weight: normal;
		color: #2a2a2a;
	}

	.claim_amt span {
		font-size: 12px;
		font-weight: normal;
		color: #797979;
	}

	.claim_amt view {
		font-size: 14px;
		font-weight: normal;
		color: #2a2a2a;
		padding: 3px 0 0px;
	}

	.total_claim .lines {
		height: 1px;
		margin: 14px 0px 0px;
		border-bottom: solid 1px #ebebeb;
	}

	.display_flex {
		display: flex;
		align-items: stretch;
	}

	.claim_dates {
		width: 30%;
		border-right: solid 1px #ebebeb;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 26px;
		font-weight: bold;
		color: #c09129;
	}

	.claim_count {
		width: 70%;
	}

	.display_space {
		display: flex;
		align-items: center;
		padding: 10px 16px;
		justify-content: space-between;
	}

	.claim_count .lines {
		height: 1px;
		margin: 0;
		background: #ebebeb;
	}

	.row {
		display: flex;
		flex-wrap: wrap;
		margin-top: calc(-1* 0);
		margin-right: calc(-.5* 1.5rem);
		margin-left: calc(-.5* 1.5rem);
	}

	.row>* {
		flex-shrink: 0;
		width: 100%;
		max-width: 100%;
		padding-right: calc(1.5rem* .5);
		padding-left: calc(1.5rem* .5);
		margin-top: 0;
	}

	.mlmr0 {
		margin-left: 0;
		margin-right: 0;
	}

	.package_top {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.package_top .right_package {
		display: flex;
		color: #c5993a;
		font-size: 16px;
		padding-right: 10px;
		align-items: center;
	}

	.package_top .right_package span {
		font-size: 14px;
		font-weight: bold;
		padding-right: 6px;
	}

	.package_top image {
		width: 50px;
		height: 50px;
	}

	.package_top .right_packageTow image {
		width: 12px;
		height: 12px;
	}

	.package_top .right_package image {
		width: 50px;
		height: 50px;
	}

	.ap_con .protect_fee {
		margin: 11px -16px 20px;
		padding: 11px 16px 12px;
		border-bottom: solid 1px #ebebeb;
		border-top: solid 1px #ebebeb;
		display: flex;
		align-items: center;
		font-size: 13px;
		font-weight: normal;
		color: #2a2a2a;
	}

	.list_row {
		display: flex;
		align-items: center;
		margin-bottom: 5px;
	}

	.list_row .col_1,
	.list_row .col_2,
	.list_row .col_3 {
		font-size: 11px;
		font-weight: normal;
		text-align: center;
		color: #a5a5a5;
	}

	.list_row .col_1 {
		width: 45%;
		text-align: left !important;
	}

	.list_row .col_2 {
		width: 15%;
	}

	.list_row .col_3 {
		width: 25%;
	}

	.head-1 {
		font-weight: bolder !important;
		color: #000 !important;
	}

	.list_row.inner_ap_list {
		padding-top: 10px;
		border-top: solid 1px #ebebeb;
		margin-bottom: 10px;
	}
	
	.cards{
		width: 100%;
		padding: 30rpx;
		border-radius: 20rpx;
		background-color: #fff;
	}
	.flex1{
		width: 100%;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		height: 70rpx;
	}
	.flex1 image{
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		margin-right: 20rpx;
	}
	.flex1 view{
		font-size: 30rpx;
	}
	.flex2{
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		margin-top: 14rpx;
	}
	.items{
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: left;
	}
	.items view{
		font-size: 26rpx;
		margin-bottom: 14rpx;
		line-height: 30rpx;
	}
	.green{
		color: green;
	}
	.red{
		color: red;
	}
	.items image{
		width: 80rpx;
		height: 80rpx;
		margin-right: 10rpx;
	}
	.flex3{
		width: 100%;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		flex-wrap: wrap;
	}
	
	.nodata{
		display: block;
		width: 300rpx;
		height: 300rpx;
		margin: 60rpx auto;
	}

	/* 底部 */
	.footer-bar {
		background-color: rgba(255, 255, 255, 0.95);
		padding: 0px 20rpx;
		position: fixed;
		bottom: 0px;
		left: 0px;
		right: 0px;
		z-index: 98;
		backdrop-filter: blur(20rpx);
		display: flex;
		text-align: center;
		transition: all 250ms ease;
		height: calc(120rpx + env(safe-area-inset-bottom));
		box-shadow: 0 -10rpx 10rpx 0 rgba(0, 0, 0, 0.04);
	}

	.footer-bar.footer-bar-detached {
		border-radius: 40rpx;
		left: 20rpx !important;
		right: 20rpx !important;
		bottom: 30rpx !important;
		box-shadow: 0 0px 30rpx 0 rgba(0, 0, 0, 0.1) !important;
		height: 120rpx !important;
	}
</style>